<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Storage;

class School extends Model
{
    use HasDateTimeFormatter;

    protected $appends = ['image_src'];

    public function faculty()
    {
        return $this->hasMany(Faculty::class);
    }

    public function unitBlock()
    {
        return $this->hasMany(UnitBlock::class);
    }

    public function banner()
    {
        return $this->hasMany(Banner::class);
    }

    public function bulletin()
    {
        return $this->hasMany(Bulletin::class);
    }

    public function commission()
    {
        return $this->hasMany(Commission::class);
    }

   /* public function getThumbnailImageAttribute($value)
    {
        return $value ? Storage::disk('admin')->url($value) : null;
    }*/

    public function imageSrc(): Attribute
    {
        return Attribute::make(get: fn() => $this->thumbnail_image ? Storage::disk('oss')->url($this->thumbnail_image) : null);
    }
}
